package com.awesome.spring.service;

import com.awesome.spring.converter.PersonConverter;
import com.awesome.spring.entity.Person;
import com.awesome.spring.entity.User;
import com.awesome.spring.model.PersonDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: awesome-spring
 * @description:
 * @author: Alex Wu
 * @createDate: 2025-02-24 17:04
 **/

@Service
public class PersonService {

    @Autowired
    private  PersonConverter personConverter;

    public Boolean savePerson() {
        Person person = new Person(1L,"音乐土豆","*****@qq.com",new Date(),new User());
        PersonDTO personDTO = personConverter.toConvertPerson(person);
        System.out.println(personDTO);
        List<Person> list = new ArrayList<>();
        list.add(person);
        List<PersonDTO> personDTOS = personConverter.toConvertList(list);
        personDTOS.forEach(personDto-> System.out.println(personDto));
        return true;
    }
}
